#!/bin/bash
export PYTHONUNBUFFERED=1

model=qwen1.8b.chat
new_date=$(date +%Y-%m-%d)_${model}
if [ ! -d "log/$new_date" ]; then
    mkdir -p "log/$new_date"
fi

model_name=Qwen-1_8B-Chat
data_type=CKnowEdit

source activate ke2torch23cu121
export HUGGINGFACE_CACHE=/share/huggingface/

batch_size=20
prob_type=target_new
# next_token之前默认是answer_next_token,也就是target_new的下一个token
next_token=argmax_next_token
layer_idx=0,24
max_tokens=128
max_sample_steps=320

data_name=type5_70
# i=0
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn}; do
#     echo "$i-$next_token-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --next_token $next_token \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$next_token-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     i=$((i+1))
# done
i=3
for ff_attrs in {mlp.c_proj,attn.c_proj}; do
    echo "$i-$next_token-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
    CUDA_VISIBLE_DEVICES=$i python kn.py \
        --next_token $next_token \
        --model_name $model_name \
        --batch_size $batch_size \
        --data_type $data_type \
        --data_path /share/dataset/CKnowEditType/$data_name.json \
        --transformer_layers_attr transformer.h \
        --ff_attrs $ff_attrs \
        --prob_type $prob_type \
        --layer_idx $layer_idx \
        --steps 20 \
        --max_tokens $max_tokens \
        --max_sample_steps $max_sample_steps \
        > log/$new_date/$i-$next_token-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
    wait
done

# i=0
# data_name=type1_133
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn,mlp.c_proj,attn.c_proj}; do
#     echo "$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     wait
# done
# i=1
# data_name=type2_80
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn,mlp.c_proj,attn.c_proj}; do
#     echo "$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     wait
# done
# batch_size=10
# i=0
# data_name=type3_40
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn}; do
#     echo "$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     i=$((i+1))
# done
# i=3
# for ff_attrs in {mlp.c_proj,attn.c_proj}; do
#     echo "$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     wait
# done
# i=3
# data_name=type6_50
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn,mlp.c_proj,attn.c_proj}; do
#     echo "$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path /share/dataset/CKnowEditType/$data_name.json \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         --max_tokens $max_tokens \
#         --max_sample_steps $max_sample_steps \
#         > log/$new_date/$i-$data_name-$model-$layer_idx-bs$batch_size-$prob_type-$ff_attrs-$max_tokens-$max_sample_steps-1.log 2>&1 &
#     wait
# done

# # type3_40
